# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=openscap
pkgver=1.3.3
pkgrel=0
pkgdesc="NIST Certified SCAP 1.2 toolkit"
url="https://www.open-scap.org/tools/openscap-base/"
arch="all"
license="LGPL-2.1-or-later"
makedepends="cmake python3-dev dbus-dev dbus-glib-dev bash libselinux-dev
	curl-dev openssl-dev libgcrypt-dev acl-dev libblkid libcap-dev libxml2-dev
	libxslt-dev openldap-dev pcre2-dev perl-xml-parser perl-xml-xpath perl-dev
	rpm-dev swig bzip2-dev asciidoc fts-dev doxygen procps-dev
	libbz2 util-linux-dev nss-dev"
options="!check"
subpackages="$pkgname-dev $pkgname-doc $pkgname-bash-completion:bashcomp:noarch"
source="https://github.com/OpenSCAP/openscap/releases/download/$pkgver/openscap-$pkgver.tar.gz
	fix-ppc64le-path_max.patch
	path_mounted.patch
	"

prepare() {
	default_prepare
	mkdir -p build
}

build() {
	cd "$builddir"/build
	export LIBS=-lfts
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DENABLE_DOCS=ON \
		-DENABLE_PERL=OFF \
		-DENABLE_TESTS=OFF\
	..
	make
}

package() {
	cd "$builddir"/build
	make DESTDIR="$pkgdir" install
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	install -Dm644 "$builddir"/dist/bash_completion.d/oscap \
		"$subpkgdir"/usr/share/bash-completion/completions/$pkgname
}

sha512sums="e230668cdf900a2f31ccabc20787dce6c4174740aa7d2cc7b91c1c095e2a5b73d81bb614aa767d2e51383b5472def360c4204e9a6c4c85110c58b9999566613e  openscap-1.3.3.tar.gz
0d8e5eb492b4439b82e35e4a87a2030f9aeff3173bda60d8ce57584fa7d7dda970ad35099e45fe46a7e135d9a55d6c2ced0a8b180556e37c7a9926de28244133  fix-ppc64le-path_max.patch
f2157d6b1d31affe16edb184a287b69d28808123f1cc26a5a4238040d935517b307772b1f2d66271b8ee99b59a4d204930f9147b78478c83c36c7fc8718ec1d9  path_mounted.patch"
